//#define __DEBUG__
#define THIS_FILE "fn_returnconfigentry.sqf"
#include "x_setup.sqf"

/*
	File: returnConfigEntry.sqf
	Author: Joris-Jan van 't Land

	Description:
	Explores parent classes in the run-time config for the value of a config entry.
	
	Parameter(s):
	_this select 0: starting config class (Config)
	_this select 1: queried entry name (String)
	
	Returns:
	Number / String - value of the found entry
*/
if (count _this < 2) exitWith {nil};
private ["_config", "_entryName"];
PARAMS_2(_config,_entryName);
if (typeName _config != typeName configFile || {typeName _entryName != typeName ""}) exitWith {nil};
private ["_entry", "_value"];
_entry = _config/_entryName;
if (configName (_config/_entryName) == "" && {!((configName _config) in ["CfgVehicles", "CfgWeapons", ""])}) then {
	[inheritsFrom _config, _entryName] call FUNC(returnConfigEntry);
} else {
	if (isNumber _entry) then {
		_value = getNumber _entry;
	} else {
		if (isText _entry) then {_value = getText _entry};
	};
};
if (isNil "_value") exitWith {nil};
_value